/**
 * 
 */
package com.UploadClasses;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.Adapters.Items.ItemUpload;
import com.Data.GeoTag;
import com.Data.Post;
import com.Managers.UserManagerClass;
import com.uploadservice.UploadService;


/**
 * @author Chris
 * 
 */
public class UploadManager implements iUploadManager {

    /*
     * (non-Javadoc)
     * @see
     * com.UploadClasses.iUploadManager#UploadPicture(android.content.Context,
     * java.lang.String[], android.content.Intent)
     */
    @Override
    public void UploadPicture(Activity activity, Post data, ItemUpload[] uploads) {

        Intent mServiceIntent = new Intent(activity, UploadService.class);

        Bundle bund = new Bundle();

        bund.putString("tags", data.getTags());
        boolean hasGeotag = UserManagerClass.UserLogged.isActiveLocation();
        bund.putBoolean("hasGeotag", hasGeotag);

        if (hasGeotag) {

            GeoTag gtag = UserManagerClass.UserLocation;
            bund.putDouble("latitude", gtag.getLatitude());
            bund.putDouble("longitude", gtag.getLongitude());
            bund.putString("city", gtag.getCity());
            bund.putString("country", gtag.getCountry());
            bund.putString("address", gtag.getAddress());

        }
        //
        bund.putInt("idOwner", data.getUser().getID());
        bund.putInt("idUser", UserManagerClass.UserLogged.getID());
        bund.putInt("albumindex", data.getAlbum().getID());
        bund.putInt("privacyindex", data.getPrivate());
        bund.putString("comment", data.getComment());

        boolean[] list = new boolean[uploads.length];
        String[] paths = new String[list.length];

        for (int i = 0; i < list.length; i++) {

            try {

                paths[i] = uploads[i].getItemup().getPathFull();

                list[i] = uploads[i].getItemup().isCover();
            }
            catch (Exception x) {

                list[i] = false;
            }

        }
        bund.putStringArray("pathList", paths);
        bund.putBooleanArray("coverList", list);
        mServiceIntent.putExtras(bund);
        mServiceIntent.putExtra("listArray", list);

        activity.startService(mServiceIntent);

    }

    /*
     * (non-Javadoc)
     * @see com.UploadClasses.iUploadManager#UploadText(com.Data.Post)
     */
    @Override
    public void UploadText(Post data) {

    }

}
